#!/bin/sh
file_rrd_name=$1
file_img_name=$2
/usr/local/rrdtool-1.2.15/bin/rrdtool graph $file_img_name/load_day.png \
--imgformat=PNG \
--start=-86400 \
--end=-300 \
--title="Load Average(day)" \
--rigid \
--base=1000 \
--height=140 \
--width=500 \
--alt-autoscale-max \
--lower-limit=0 \
--units-exponent=0 \
--vertical-label="processes in the run queue" \
DEF:a="$file_rrd_name/load_1min":load_1min:AVERAGE \
DEF:b="$file_rrd_name/load_5min":load_5min:AVERAGE \
DEF:c="$file_rrd_name/load_15min":load_15min:AVERAGE \
LINE1:a#00CF00:"1 Minute Average"  \
GPRINT:a:LAST:" Current\:%8.2lf"  \
GPRINT:a:AVERAGE:"Average\:%8.2lf"  \
GPRINT:a:MAX:"Maximum\:%8.2lf\n"  \
LINE1:b#002A97:"5 Minute Average"  \
GPRINT:b:LAST:" Current\:%8.2lf"  \
GPRINT:b:AVERAGE:"Average\:%8.2lf"  \
GPRINT:b:MAX:"Maximum\:%8.2lf\n"  \
LINE1:c#FF0000:"15 Minute Average"  \
GPRINT:c:LAST:"Current\:%8.2lf"  \
GPRINT:c:AVERAGE:"Average\:%8.2lf"  \
GPRINT:c:MAX:"Maximum\:%8.2lf\n" 

/usr/local/rrdtool-1.2.15/bin/rrdtool graph $file_img_name/load_weekly.png \
--imgformat=PNG \
--start=-604800 \
--end=-1800 \
--title="Load Average(weekly)" \
--rigid \
--base=1000 \
--height=140 \
--width=500 \
--alt-autoscale-max \
--lower-limit=0 \
--units-exponent=0 \
--vertical-label="processes in the run queue" \
DEF:a="$file_rrd_name/load_1min":load_1min:AVERAGE \
DEF:b="$file_rrd_name/load_5min":load_5min:AVERAGE \
DEF:c="$file_rrd_name/load_15min":load_15min:AVERAGE \
LINE1:a#00CF00:"1 Minute Average"  \
GPRINT:a:LAST:" Current\:%8.2lf"  \
GPRINT:a:AVERAGE:"Average\:%8.2lf"  \
GPRINT:a:MAX:"Maximum\:%8.2lf\n"  \
LINE1:b#002A97:"5 Minute Average"  \
GPRINT:b:LAST:" Current\:%8.2lf"  \
GPRINT:b:AVERAGE:"Average\:%8.2lf"  \
GPRINT:b:MAX:"Maximum\:%8.2lf\n"  \
LINE1:c#FF0000:"15 Minute Average"  \
GPRINT:c:LAST:"Current\:%8.2lf"  \
GPRINT:c:AVERAGE:"Average\:%8.2lf"  \
GPRINT:c:MAX:"Maximum\:%8.2lf\n" 

/usr/local/rrdtool-1.2.15/bin/rrdtool graph $file_img_name/load_monthly.png \
--imgformat=PNG \
--start=-2678400 \
--end=-7200 \
--title="Load Average(montyly)" \
--rigid \
--base=1000 \
--height=140 \
--width=500 \
--alt-autoscale-max \
--lower-limit=0 \
--units-exponent=0 \
--vertical-label="processes in the run queue" \
DEF:a="$file_rrd_name/load_1min":load_1min:AVERAGE \
DEF:b="$file_rrd_name/load_5min":load_5min:AVERAGE \
DEF:c="$file_rrd_name/load_15min":load_15min:AVERAGE \
LINE1:a#00CF00:"1 Minute Average"  \
GPRINT:a:LAST:" Current\:%8.2lf"  \
GPRINT:a:AVERAGE:"Average\:%8.2lf"  \
GPRINT:a:MAX:"Maximum\:%8.2lf\n"  \
LINE1:b#002A97:"5 Minute Average"  \
GPRINT:b:LAST:" Current\:%8.2lf"  \
GPRINT:b:AVERAGE:"Average\:%8.2lf"  \
GPRINT:b:MAX:"Maximum\:%8.2lf\n"  \
LINE1:c#FF0000:"15 Minute Average"  \
GPRINT:c:LAST:"Current\:%8.2lf"  \
GPRINT:c:AVERAGE:"Average\:%8.2lf"  \
GPRINT:c:MAX:"Maximum\:%8.2lf\n" 

/usr/local/rrdtool-1.2.15/bin/rrdtool graph $file_img_name/load_yearly.png \
--imgformat=PNG \
--start=-33053184 \
--end=-86400 \
--title="Load Average(yearly)" \
--rigid \
--base=1000 \
--height=140 \
--width=500 \
--alt-autoscale-max \
--lower-limit=0 \
--units-exponent=0 \
--vertical-label="processes in the run queue" \
DEF:a="$file_rrd_name/load_1min":load_1min:AVERAGE \
DEF:b="$file_rrd_name/load_5min":load_5min:AVERAGE \
DEF:c="$file_rrd_name/load_15min":load_15min:AVERAGE \
LINE1:a#00CF00:"1 Minute Average"  \
GPRINT:a:LAST:" Current\:%8.2lf"  \
GPRINT:a:AVERAGE:"Average\:%8.2lf"  \
GPRINT:a:MAX:"Maximum\:%8.2lf\n"  \
LINE1:b#002A97:"5 Minute Average"  \
GPRINT:b:LAST:" Current\:%8.2lf"  \
GPRINT:b:AVERAGE:"Average\:%8.2lf"  \
GPRINT:b:MAX:"Maximum\:%8.2lf\n"  \
LINE1:c#FF0000:"15 Minute Average"  \
GPRINT:c:LAST:"Current\:%8.2lf"  \
GPRINT:c:AVERAGE:"Average\:%8.2lf"  \
GPRINT:c:MAX:"Maximum\:%8.2lf\n" 
